package ro.gateway.aida.admin;

import java.util.ArrayList;

import org.apache.struts.action.ActionForm;

/**
 * Created by IntelliJ IDEA.
 * User: smike
 * Date: Apr 20, 2004
 * Time: 8:36:14 PM
 * To change this template use File | Settings | File Templates.
 */
public class PropertyListSelector$Form extends ActionForm {
	public String action;
	public String event;
	int[] idxs;
	public PropertyList list = new PropertyList();
	public ArrayList selected = new ArrayList();

	public void setViewLang(String lang) {
		if (list != null) {
			list.setViewLang(lang);
		}
	}

	public boolean contains(long id) {
		for (int i = 0; i < selected.size(); i++) {
			PropertyListItem item = (PropertyListItem) selected.get(i);
			if (item.getId() == id) return true;
		}
		return false;
	}

	public int[] getIdxs() {
		return idxs;
	}

	public void setIdxs(int[] idxs) {
		this.idxs = idxs;
	}

	public ArrayList getSelected() {
		return selected;
	}

	public void setSelected(ArrayList selected) {
		this.selected = selected;
	}

	public PropertyList getList() {
		return list;
	}

	public void setList(PropertyList list) {
		this.list = list;
	}

	public String getAction() {
		return action;
	}

	public void setAction(String action) {
		this.action = action;
	}

	public String getEvent() {
		return event;
	}

	public void setEvent(String event) {
		this.event = event;
	}

	public String getSelectedIds() {
		if (selected == null || selected.size() < 1) return "";

		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < selected.size(); i++) {
			PropertyListItem propertyListItem = (PropertyListItem) selected.get(i);
			if (i > 0) sb.append(",");
			sb.append(propertyListItem.getId());
		}
		return sb.toString();
	}
}
